package com.example.houduan.Service.Impl;

import com.example.houduan.Mapper.SaleMapper;
import com.example.houduan.Pojo.Sale;
import com.example.houduan.Service.SaleService;
import com.example.houduan.Utils.PageModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SaleServiceImpl implements SaleService {

    @Autowired
    SaleMapper saleMapper;

    @Override
    public PageModel getSalePage(int num, int size) {
        int count=saleMapper.selectSaleCount();
        PageModel pm=new PageModel(num,count,size);
        pm.setList(saleMapper.selectSaleLimit((num-1)*size,size));
        return pm;
    }

    @Override
    public int deleteSale(Integer sale_id) {
        return saleMapper.deleteSale(sale_id);
    }

    @Override
    public int updateSale(Sale sale) {
        return saleMapper.updateSale(sale);
    }

    @Override
    public int addSale(Sale sale) {
        return saleMapper.insertSale(sale);
    }

    @Override
    public List<Sale> getSaleByConditions(Integer sale_id, String sale_name, String city_name) {
        return saleMapper.selectSaleByConditions(sale_id,sale_name,city_name);
    }
}
